core.ui.dialog=(function(){

    var defaultOptions={
        transition:"scale",
        allowMultiple:true,
        useCSS:true,
        closable:false
    };

    component.run(['$rootScope',function($rootScope) {
        $rootScope.$on('$locationChangeStart', function(){
            $(".ui.dimmer.modals").remove();
        });
    }]);

    var dialog=function(element,options,showCallback,closeCallback){
        options=$.extend({},defaultOptions,options);

        var $dialog=$(element);

        options.onShow=function(){
            if(objectUtil.isNull(showCallback)) {
                return;
            }

            showCallback($dialog);
        };

        options.onHide=function(){
            if(objectUtil.isNull(closeCallback)) {
                return;
            }

            closeCallback($dialog);
        };

        $dialog.modal('setting',options).modal("show");

        $dialog.close=function(){
            $dialog.modal("hide");
        };

        return $dialog;
    };

    return dialog;
})();